package com.um.jdy.mp.report.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.um.springboot.starter.entity.Page;
import com.um.jdy.mp.report.entity.vo.OrderDataItemVO;
import com.um.jdy.mp.report.entity.vo.OrderItemVO;
import com.um.jdy.mp.report.entity.vo.OrderSummaryVO;
import com.um.jdy.mp.report.entity.vo.StationOrderItemVO;
import com.um.jdy.mp.report.enums.DateType;
import com.um.jdy.mp.report.service.OrderDataService;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 订单统计
 *
 * @author cs
 * 日期 2023/5/23
 * 版权所有 广州优匠科技有限公司
 */
@Api(tags = "订单统计")
@Validated
@RestController
@RequestMapping("/api/v1/order_data")
@SaCheckLogin
public class OrderDataController {

    @Autowired
    OrderDataService orderDataService;

    @ApiOperation(value = "累计数据")
    @GetMapping("summary")
    public Response<OrderSummaryVO> getOrderSummary() {
        return Response.success(orderDataService.getOrderSummary());
    }

    @ApiOperation(value = "订单统计")
    @GetMapping("list")
    public Response<List<OrderDataItemVO>> getOrderData(@ApiParam(value = "时间") DateType data_type,
                                                        @ApiParam(value = "站场ID") String station_id) {
        return Response.success(orderDataService.getOrderData(data_type, station_id));
    }

    @ApiOperation(value = "分页查询设备订单")
    @GetMapping("device_order/page")
    public Response<Page<OrderItemVO>> getDeviceOrderPage(@ApiParam(value = "页码") @NotNull Integer page_no,
                                                          @ApiParam(value = "数据量") @NotNull Integer page_size,
                                                          @ApiParam(value = "时间") DateType data_type,
                                                          @ApiParam(value = "站场ID") String station_id) {
        return Response.success(orderDataService.getDeviceOrderPage(page_no, page_size, data_type, station_id));
    }

    @ApiOperation(value = "分页查询站场订单")
    @GetMapping("station_order/page")
    public Response<Page<StationOrderItemVO>> getStationOrderPage(@ApiParam(value = "页码") @NotNull Integer page_no,
                                                                  @ApiParam(value = "数据量") @NotNull Integer page_size,
                                                                  @ApiParam(value = "时间") DateType data_type) {
        return Response.success(orderDataService.getStationOrderPage(page_no, page_size, data_type));
    }

}
